package com.wanhe.viewconf.views.child;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;

import com.wanhe.base.model.disgn.Event;
import com.wanhe.base.model.disgn.ViewEvent;
import com.wanhe.viewconf.views.child.interfaces.IViewReady;

/**
 * File Name:MealBookHitView.java<br/>
 * Package Name:com.wanhe.viewconf.views.child<br/>
 * Date:2017/7/11 15:27<br/>
 * author:chendeji<br/>
 * desc: 热区子控件，主要是用来<br/>
 * Copyright (c) 2017/7/11, 781571323@qq.com All Rights Reserved.
 *
 */
public class MealBookHitView extends MealBookChildItemView {
	public static final String TAG = "MealBookHitView";

	public MealBookHitView(Context context) {
		super(context);
		setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				callSendEventMsg();
			}
		});
	}

	@Override
	public void tap(Event event, ViewEvent.Coor coor) {
		super.tap(event, coor);
		callSendEventMsg();
	}

	@Override
	public void show(Event event, ViewEvent.Coor coor) {
		super.show(event, coor);
		if (this.mItem.getType().equals("highlight")) {
			layout(coor.l, coor.t, coor.r, coor.b);
			invalidate();
		}
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		/**
		 * 如果是点击高亮区，需要画出边框颜色要根据给出颜色来显示
		 * 
		 * @author 陈德基
		 * @time 2017/7/13 11:46
		 */
		if (this.mItem.getType().equals("highlight")) {
			Rect clipBounds = canvas.getClipBounds();
			Paint paint = new Paint();
			paint.setColor(getColor());
			paint.setStyle(Paint.Style.STROKE);
			paint.setStrokeWidth(20);
			canvas.drawRect(clipBounds, paint);
		}
	}
}
